import ApiConfigDto from '@/core/framework/config/types/model/ApiConfigDto'
import { TableColumn } from 'amis/lib/renderers/Table'
import { ApiObject } from 'amis-core/lib/types'
import { SchemaObject, SchemaTpl } from 'amis/lib/Schema'
import { ActionSchema } from 'amis'
import { CRUDBultinToolbarType, CRUDToolbarChild, CRUDToolbarObject } from 'amis/lib/renderers/CRUD'

export type DefaultCrudTableServerApi =
	| (Partial<ApiObject> & {
			// 接口配置 优先级 apiConfig > 原生配置
			apiConfig: ApiConfigDto
	  })
	| undefined

export declare type DefaultCrudTableProps = {
	// 列表标题 优先级 entityTitle > title
	title?: string
	// 实体名称 优先级 entityTitle > title
	entityTitle: string
	primaryField?: string
	columns: TableColumn[]
	addServerApi: DefaultCrudTableServerApi
	editServerApi: DefaultCrudTableServerApi
	deleteServerApi: DefaultCrudTableServerApi
	searchServerApi: DefaultCrudTableServerApi
	detailServerApi: DefaultCrudTableServerApi
	formItems: Array<SchemaObject | SchemaTpl>
	// 操作列按钮
	operationButtons?: Array<SchemaObject | SchemaTpl>
	// 工具栏按钮
	toolButtons?: Array<(CRUDToolbarChild & CRUDToolbarObject) | CRUDBultinToolbarType> | undefined
	debug?: boolean
	// 编辑器类型
	editorType?: 'dialog' | 'drawer'
	// 编辑表单数据
	editorFormData?: any
	// 新增表单数据
	newFormData?: any
	editButton?: Partial<ActionSchema>
}
export default DefaultCrudTableProps
